function TooltipScan:CreateFrame()
	if not self.options.frame then
		local f = CreateFrame("Frame", "BonusesOptionFrame", UIParent)
		f:SetWidth(300)
		f:SetHeight(335)
		f:SetFrameStrata("LOW")

		f:SetMovable(true)
		f:SetUserPlaced(true)
		f:EnableMouse(true)
		f:RegisterForDrag("LeftButton")

		f:SetScript("OnDragStart", function()
			f:StartMoving()
		end)
		f:SetScript("OnDragStop", function()
			f:StopMovingOrSizing()
		end)

		f:SetBackdrop({
			bgFile = "Interface\\ChatFrame\\ChatFrameBackground", tile = true, tileSize = 32,
			edgeFile = "Interface\\AddOns\\Bonuses\\Textures\\border", edgeSize = 32,
			insets = {left = 1, right = 1, top = 20, bottom = 20},
		})
		f:SetBackdropColor(0,0,0,0.7)
		
		f:SetPoint("CENTER", UIParent)
		
		f.Title = f:CreateFontString(nil, "OVERLAY")
		f.Title:SetPoint("TOPLEFT", f, "TOPLEFT", 5, -14)
		f.Title:SetFont(STANDARD_TEXT_FONT, 12)
		f.Title:SetShadowOffset(.8, -.8)
		f.Title:SetShadowColor(0, 0, 0, 1)
		f.Title:SetText("Bonuses Options")
		
		f.Close = CreateFrame("Button", nil, f, "UIPanelButtonGrayTemplate")
		f.Close:SetWidth(20)
		f.Close:SetHeight(20)
		f.Close:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, -10)
		f.Close:SetBackdropColor(1,1,1)
		f.Close:SetText("X")
		f.Close:SetScript("OnClick", function()
			f:Hide()
		end)
		local temp = nil
		temp = self:CreateTitle("Base Stats", f, 5,-30, true)
		temp = self:CreateCheckbox("STR", temp, 0,0)
		temp = self:CreateCheckbox("STA", temp, 0,0)
		temp = self:CreateCheckbox("AGI", temp, 0,0)
		temp = self:CreateCheckbox("INT", temp, 0,0)
		temp = self:CreateCheckbox("SPI", temp, 0,0)
		temp = self:CreateCheckbox("ARMOR", temp, 0,0)
		temp = self:CreateTitle("Resistances", temp, 0,-5)
		temp = self:CreateCheckbox("FIRE_RESIST", temp, 0,0)
		temp = self:CreateCheckbox("FROST_RESIST", temp, 0,0)
		temp = self:CreateCheckbox("NATURE_RESIST", temp, 0,0)
		temp = self:CreateCheckbox("SHADOW_RESIST", temp, 0,0)
		temp = self:CreateCheckbox("ARCANE_RESIST", temp, 0,0)
		temp = self:CreateTitle("Melee Stats", temp, 0,-5)
		temp = self:CreateCheckbox("AP", temp, 0,0)
		temp = self:CreateCheckbox("CR_MELEE_CRIT", temp, 0,0)
		temp = self:CreateCheckbox("CR_MELEE_HIT", temp, 0,0)
		temp = self:CreateCheckbox("CR_MELEE_HASTE", temp, 0,0)
		temp = self:CreateCheckbox("CR_WEAPON_SKILL", temp, 0,0)
		temp = self:CreateTitle("Misc Stats", temp, 0,-5)
		temp = self:CreateCheckbox("FERAL_AP", temp, 0,0)
		temp = self:CreateCheckbox("RESILIENCE", temp, 0,0)
		
		
		temp = self:CreateTitle("Casting Stats", f, 160,-30, true)
		temp = self:CreateCheckbox("MP5", temp, 0,0)
		temp = self:CreateCheckbox("CR_SPELL_CRIT", temp, 0,0)
		temp = self:CreateCheckbox("CR_SPELL_HIT", temp, 0,0)
		temp = self:CreateCheckbox("CR_SPELL_HASTE", temp, 0,0)
		temp = self:CreateCheckbox("DMG", temp, 0,0)
		temp = self:CreateCheckbox("HEAL", temp, 0,0)
		temp = self:CreateCheckbox("FIRE_DMG", temp, 0,0)
		temp = self:CreateCheckbox("FROST_DMG", temp, 0,0)
		temp = self:CreateCheckbox("NATURE_DMG", temp, 0,0)
		temp = self:CreateCheckbox("SHADOW_DMG", temp, 0,0)
		temp = self:CreateCheckbox("ARCANE_DMG", temp, 0,0)
		temp = self:CreateCheckbox("SPELL_PENETRATION", temp, 0,0)
		temp = self:CreateTitle("Defensive Stats", temp, 0,-5)
		temp = self:CreateCheckbox("CR_DEFENSE", temp, 0,0)
		temp = self:CreateCheckbox("CR_DODGE", temp, 0,0)
		temp = self:CreateCheckbox("CR_BLOCK", temp, 0,0)
		temp = self:CreateCheckbox("CR_PARRY", temp, 0,0)
		temp = self:CreateCheckbox("BLOCK_VALUE", temp, 0,0)
		
		tinsert(UISpecialFrames,"BonusesOptionFrame")
		f:Show()
		self.options.frame = f
	else
		self.options.frame:Show()
	end
end

function TooltipScan:CreateCheckbox(stat, topframe, x, y)
	local c = CreateFrame("CheckButton", nil, BonusesOptionFrame, "UICheckButtonTemplate")
	c:SetFrameStrata("HIGH")
	c:SetWidth(12)
	c:SetHeight(12)
	c:SetPoint("TOPLEFT", topframe, "BOTTOMLEFT", x, y)
	c:SetScript("OnClick", function()
		TooltipScan:SetOption(c, stat)
	end)
	if not self:ClassIgnore(stat) then
		c:SetChecked(true)
	end
	--[[
	c.Title:SetPoint("TOPLEFT", c, "TOPRIGHT", 5, 0)
	c.Title:SetFont(STANDARD_TEXT_FONT, 12)
	c.Title:SetTextColor(1,1,1)
	c.Title:SetText(self.NAMES[stat])
	]]--
	
	c.Title = self:CreateTitle(self.NAMES[stat], c, 17, 0, true)
	
	return c
end

function TooltipScan:CreateTitle(text, topframe, x, y, top)
	local t = BonusesOptionFrame:CreateFontString(nil, "OVERLAY")
	if top then
		t:SetPoint("TOPLEFT", topframe, "TOPLEFT", x, y)
	else
		t:SetPoint("TOPLEFT", topframe, "BOTTOMLEFT", x, y)
	end
	t:SetFont(STANDARD_TEXT_FONT, 12)
	t:SetText(text)
	
	return t
end

function TooltipScan:SetOption(button, stat)
	if button:GetChecked() then
		self:Debug(stat, "false")
		self.db.profile.overridestat[stat] = false
	else
		self:Debug(stat, "true")
		self.db.profile.overridestat[stat] = true
	end
end
